#! /usr/bin/python
import os

print '<table>'
col = 0
for dir in os.popen('ls ..').readlines():
  if dir[:5] == 'Rule ':
    if col == 0:
      print '<tr valign=top>'
    print '<td>'
    print '<table border>'
    print '<tr><th colspan=2 align=center>Rule ' + str(int(dir[-4:-1])) + '</th></tr>'
    print '<tr><th align=center>Type</th><th align=center>Number</th></tr>'
    prevType = ''
    for file in os.popen('ls "../' + dir[:-1] + '"').readlines():
      if file.strip()[-4:] == '.sqc':
        type = file[:-8]
        if type == prevType:
          cnt = cnt + 1
        else:
          if prevType != '':
            print '<tr><td align=left>' + prevType + '</td><td align=right>' + str(cnt) + '</td></tr>'
          cnt = 1
          prevType = type
    print '<tr><td align=left>' + type + '</td><td align=right>' + str(cnt) + '</td></tr>'
    print '</table></td>'
    col = col + 1
    if col == 6:
      print '</tr>'
      col = 0
print '</table>'
